<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>注册</title>
    <link rel="stylesheet" type="text/css" href="../static/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="../static/xznstatic/css/public.css"/>
    <link rel="stylesheet" type="text/css" href="../static/xznstatic/css/login.css"/>
    <style type="text/css">
        .register {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 100%;
            background-attachment: fixed;
            background-size: cover;
            background-position: center;
            background-image: url(http://codegen.caihongy.cn/20210109/e702e3d18f9f4038a3a5f0594ee72e98.jpg);

        }
        .register form {
            box-sizing: border-box;
            min-height: 400px;
            display: flex;
            flex-direction: column;
            justify-content: center !important;
        }
        .register .logo, .register .title {
            box-sizing: border-box;
        }
        .register .logo img {
            display: block;
        }
        .register .title {
            text-align: center;
        }
        .register .form-item {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            box-sizing: border-box;
        }
        .register .form-item input, .register .form-label {
            box-sizing: border-box;
        }
        .register .btn-submit {
            display: block;
            box-sizing: border-box;
        }
        .register form p.txt {
            width: 100%;
            margin: 0;
            box-sizing: border-box;
        }
        .btns{
            width: 120px;
            height: 30px;
            border: 0px;
            background:#86939e;

            margin-top:10px ;
        }
    </style>
</head>
<body>
<div class="register" id="app">
    <form class="layui-form login-form" th:action="@{/regist}" method="post" :style='{"padding":"20px","boxShadow":"0 0 20px #e0dedc","borderColor":"rgba(0,0,0,.3)","backgroundColor":"#fff","borderRadius":"20px","borderWidth":"0","width":"400px","borderStyle":"solid","justifyContent":"center","height":"auto"}'>
        <h1 class="logo" v-if="false" :style='{"padding":"5px 0","boxShadow":"0 0 6px rgba(255,0,0,.8)","borderColor":"rgba(0,0,0,.3)","backgroundColor":"#fff","borderRadius":"6px","borderWidth":"0","borderStyle":"solid"}'><img :style='{"boxShadow":"0 0 6px rgba(255,0,0,.8)","margin":"0 auto","borderColor":"rgba(0,0,0,.3)","borderRadius":"100%","borderWidth":"1px","width":"44px","borderStyle":"solid","height":"44px"}' src="http://codegen.caihongy.cn/20201024/ed5e326ca66f403aa3197b5fbb4ec733.jpg"></h1>
        <p class="title" v-if="true" :style='{"padding":"0 10px","boxShadow":"","margin":"10px auto","borderColor":"rgba(0,0,0,1)","backgroundColor":"rgba(255, 255, 255, 1)","color":"rgba(254, 103, 76, 1)","isshow":true,"borderRadius":"8px","borderWidth":"0","width":"100%","lineHeight":"32px","fontSize":"16px","borderStyle":"solid"}'>注册</p>
        <div :style='{"padding":"0","boxShadow":"","margin":"0 auto","borderColor":"rgba(0,0,0,1)","backgroundColor":"#fff","borderRadius":"0","borderWidth":"0 0 1px 0","width":"80%","borderStyle":"solid","height":"50px"}' class="form-item layui-form-text">
            <label v-if="false" :style='{"padding":"0 10px","boxShadow":"","borderColor":"rgba(0,0,0,0)","backgroundColor":"transparent","color":"#333","borderRadius":"0","textAlign":"right","borderWidth":"0","width":"84px","fontSize":"16px","borderStyle":"solid"}' class="form-label">登录名：</label>
            <input :style='{"padding":"0 10px","boxShadow":"","borderColor":"#ccc","backgroundColor":"rgba(255, 255, 255, 1)","color":"#333","borderRadius":"8px","textAlign":"left","borderWidth":"0","width":"100%","fontSize":"14px","borderStyle":"solid","height":"44px"}' type="text" id="loginname" name="loginname" placeholder="请输入账号" autocomplete="off" class="layui-input">
        </div>
        <div :style='{"padding":"0","boxShadow":"","margin":"0 auto","borderColor":"rgba(0,0,0,1)","backgroundColor":"#fff","borderRadius":"0","borderWidth":"0 0 1px 0","width":"80%","borderStyle":"solid","height":"50px"}' class="form-item">
            <label v-if="false" :style='{"padding":"0 10px","boxShadow":"","borderColor":"rgba(0,0,0,0)","backgroundColor":"transparent","color":"#333","borderRadius":"0","textAlign":"right","borderWidth":"0","width":"84px","fontSize":"16px","borderStyle":"solid"}' class="form-label">密码：</label>
            <input :style='{"padding":"0 10px","boxShadow":"","borderColor":"#ccc","backgroundColor":"rgba(255, 255, 255, 1)","color":"#333","borderRadius":"8px","textAlign":"left","borderWidth":"0","width":"100%","fontSize":"14px","borderStyle":"solid","height":"44px"}' type="password"  name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
        <div :style='{"padding":"0","boxShadow":"","margin":"0 auto","borderColor":"rgba(0,0,0,1)","backgroundColor":"#fff","borderRadius":"0","borderWidth":"0 0 1px 0","width":"80%","borderStyle":"solid","height":"50px"}' class="form-item layui-form-text">
            <label v-if="false" :style='{"padding":"0 10px","boxShadow":"","borderColor":"rgba(0,0,0,0)","backgroundColor":"transparent","color":"#333","borderRadius":"0","textAlign":"right","borderWidth":"0","width":"84px","fontSize":"16px","borderStyle":"solid"}' class="form-label">用户名：</label>
            <input :style='{"padding":"0 10px","boxShadow":"","borderColor":"#ccc","backgroundColor":"rgba(255, 255, 255, 1)","color":"#333","borderRadius":"8px","textAlign":"left","borderWidth":"0","width":"100%","fontSize":"14px","borderStyle":"solid","height":"44px"}' type="text" id="chezhuxingming" name="uname" placeholder="请输入用户名" autocomplete="off" class="layui-input">
        </div>
        <div :style='{"padding":"0","boxShadow":"","margin":"0 auto","borderColor":"rgba(0,0,0,1)","backgroundColor":"#fff","borderRadius":"0","borderWidth":"0 0 1px 0","width":"80%","borderStyle":"solid","height":"50px"}' class="form-item layui-form-text">
            <label v-if="false" :style='{"padding":"0 10px","boxShadow":"","borderColor":"rgba(0,0,0,0)","backgroundColor":"transparent","color":"#333","borderRadius":"0","textAlign":"right","borderWidth":"0","width":"84px","fontSize":"16px","borderStyle":"solid"}' class="form-label">手机号：</label>
            <input :style='{"padding":"0 10px","boxShadow":"","borderColor":"#ccc","backgroundColor":"rgba(255, 255, 255, 1)","color":"#333","borderRadius":"8px","textAlign":"left","borderWidth":"0","width":"100%","fontSize":"14px","borderStyle":"solid","height":"44px"}' type="text" id="lianxifangshi" name="telephone" placeholder="请输入手机号" onblur="tip()"autocomplete="off" class="layui-input">
            <div class="tip"></div>
        </div>
        <div class="form-group" align="center">
        <input type="submit" class="btns" onmouseover="this.style.backgroundPosition='left -40px'"
               onmouseout="this.style.backgroundPosition='left top'" value="注册"/>
        </div>
        <p :style='{"color":"#999","textAlign":"right","fontSize":"12px"}' class="txt"><a th:href="@{/login}" >已有账号登录</a></p>

    </form>
</div>
<script>
    function tip(){
        var num = /^[0-9]*$/;
        if (!num.test(document.getElementsByClassName("telephone")[i].value)) {
            document.getElementsByClassName("tip")[i].innerHTML = '只能为数字'
        }
    }
</script>
<script src="../static/layui/layui.js"></script>
<script src="../static/js/vue.js"></script>
<!-- 组件配置信息 -->
<script src="../static/js/config.js"></script>
<!-- 扩展插件配置信息 -->
<script src="../static/modules/config.js"></script>
<!-- 工具方法 -->
<script src="../static/js/utils.js"></script>
<!-- 校验格式工具类 -->
<script src="../static/js/validate.js"></script>

<script>
    var vue = new Vue({
        el: '#app',
        data: {

        },
        methods: {

        }
    });

    layui.use(['layer', 'element', 'carousel', 'form', 'http', 'jquery'], function() {
        var layer = layui.layer;
        var element = layui.element;
        var carousel = layui.carousel;
        var form = layui.form;
        var http = layui.http;
        var jquery = layui.jquery;

        var tablename = http.getParam('tablename');

        // 注册
        form.on('submit(register)', function(data) {
            data = data.field;
            if(!data.uname){
                layer.msg('车主账号不能为空', {
                    time: 2000,
                    icon: 5
                });
                return false
            }
            if(!data.password){
                layer.msg('密码不能为空', {
                    time: 2000,
                    icon: 5
                });
                return false
            }
            if(!isMobile(data.telephone)){
                layer.msg('联系方式应输入手机格式', {
                    time: 2000,
                    icon: 5
                });
                return false
            }
            // if(!isEmail(data.chezhuyouxiang)){
            //     layer.msg('车主邮箱应输入邮箱格式', {
            //         time: 2000,
            //         icon: 5
            //     });
            //     return false
            // }
            // if(!isIdentity(data.)){
            //     layer.msg('身份证应输入身份证格式', {
            //         time: 2000,
            //         icon: 5
            //     });
            //     return false
            // }
            http.requestJson(tablename + '/register', 'post', data, function(res) {
                layer.msg('注册成功', {
                    time: 2000,
                    icon: 6
                },function(){
                    // 路径访问设置
                    window.location.href = '/login';
                });
            });
            return false
        });
    });
</script>
<script type="text/javascript">
    var msg = "[[${session.msg}]]";
    // alert(msg);
    if (msg != "" && msg.length >0){
        alert(msg);

    }
</script>
</body>
</html>

